
<template>
  <div>
    <el-form :inline="true" class="demo-form-inline">

      <el-form-item label="  登记时间" style="width: 220px">
        <el-date-picker
            style="width: 150px"
            v-model="allBugInfosParam.startTime"
            type="date"
            placeholder="选择开始日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="~">
        <el-date-picker
            style="width: 150px"
            v-model="allBugInfosParam.endTime"
            type="date"
            placeholder="选择结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="项目">
        <el-select v-model="allBugInfosParam.projectId" placeholder="项目名称" clearable  style="width: 100px">
          <el-option v-for="project in projects" :key="project.projectId" :label="project.projectName" :value="project.projectId"  ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="状态">
        <el-select v-model="allBugInfosParam.status" placeholder="状态" clearable style="width: 100px">
          <el-option v-for="statu in status" :key="statu.name" :label="statu.name" :value="statu.value"  ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="getBugInfors()">查询</el-button>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="dialogFormVisible=true,selectProject()">新增</el-button>
        <el-dialog title="新增任务" :visible.sync="dialogFormVisible">
          <el-form :model="addAndEditBugInfo">
            <el-form-item label="项目名称" :label-width="formLabelWidth" >
              <el-select v-model="addAndEditBugInfo.projectId" placeholder="请选择项目名称" >
                <el-option v-for="newproject in newprojects" :key="newproject.projectId" :label="newproject.projectName" :value="newproject.projectId"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="父级缺陷" :label-width="formLabelWidth">
              <el-input v-model="addAndEditBugInfo.parentIssueId" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="缺陷名称" :label-width="formLabelWidth">
              <el-input v-model="addAndEditBugInfo.bugNum" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="缺陷描述" :label-width="formLabelWidth">
              <el-input v-model="addAndEditBugInfo.bugDesc" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="缺陷要求" :label-width="formLabelWidth">
              <el-input v-model="addAndEditBugInfo.doneCondition" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="缺陷分类" :label-width="formLabelWidth">
              <el-select v-model="addAndEditBugInfo.bugTypeId" placeholder="请选择缺陷分类">
                <el-option v-for="bugType  in bugTypes" :key="bugType.bugTypeId" :label="bugType.bugTypeName" :value="bugType.bugTypeId"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="严重程度" :label-width="formLabelWidth">
              <el-select v-model="addAndEditBugInfo.severityId" placeholder="请选择严重程度">
                <el-option v-for="savarity in savarityes" :key="savarity.savarityId" :label="savarity.savarityLev" :value="savarity.savarityId"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="优先级" :label-width="formLabelWidth">
              <el-select v-model="addAndEditBugInfo.PriorityId" placeholder="请选择严重程度">
                <el-option v-for="priority in priorityes" :key="priority.priorityId" :label="priority.priorityLev" :value="priority.priorityId"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
          <el-form-item label="预计工时" :label-width="formLabelWidth">
            <el-input v-model="addAndEditBugInfo.planWorkHours" autocomplete="off"></el-input>
          </el-form-item>
          <br>
          <el-form-item label="计划开始时间" :label-width="formLabelWidth">
            <el-input type="date" v-model="addAndEditBugInfo.planStartTime" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="计划完成时间" :label-width="formLabelWidth">
            <el-input type="date" v-model="addAndEditBugInfo.planEndTime" autocomplete="off"></el-input>
          </el-form-item>
          <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisible = false">取 消</el-button>
            <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
          </div>
        </el-dialog>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="delSelects">删除</el-button>
      </el-form-item>
    </el-form>


    <el-table
        :data="tableData"
        border
        style="width: 100%">
      @selection-change="handleSelectionChange">
      <el-table-column
          type="selection"
          width="55">
      </el-table-column>

      <el-table-column
          fixed
          prop="bugId"
          label="编号"
          width="150">
      </el-table-column>
      <el-table-column
          prop="projectId"
          label="项目名称"
          width="120">
      </el-table-column>
      <el-table-column
          prop="bugNum"
          label="任务名称"
          width="120">
      </el-table-column>
      <el-table-column
          prop="parentIssueId"
          label="父任务"
          width="120">
      </el-table-column>
      <el-table-column
          prop="priorityLev"
          label="优先级"
          width="300">
      </el-table-column>
      <el-table-column
          prop="savarityLev"
          label="严重程度"
          width="120">
      </el-table-column>
      <el-table-column
          prop="bugTypeName"
          label="缺陷分类"
          width="120">
      </el-table-column>
      <el-table-column

          label="状态"
          width="120">
        <template slot-scope="scope">
                    {{status[scope.row.bugState].name}}
        </template>
      </el-table-column>
      <el-table-column
          prop="assignee"
          label="指派"
          width="120">
      </el-table-column>
      <el-table-column
          prop="planEndTime"
          label="计划完成时间"
          width="120">
      </el-table-column>
      <el-table-column
          fixed="right"
          label="操作"
          width="100">
<!--        <template slot-scope="scope">-->
<!--          <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>-->
<!--        </template>-->
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
          <el-button type="text" size="small">修改</el-button>
          <el-button type="text" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

  </div>
</template>

<script>
export default {
  name: "buglist",

  methods: {
    handleClick(row) {
      console.log(row);
    },
    getBugInfors() {
      this.$http.post("/bugInfo/getAll", this.allBugInfosParam)
          .then(resp => {
            console.log("getBugInfors===================");
            console.log(resp);
            this.tableData = resp.data.data.bugs;
          })
    },
    onSubmit() {
      this.$http.post("/bugInfo/getAll", this.allBugInfosParam)
          .then(resp => {
            this.tableData = resp.data.data.bugs;
          })

    },
    getProjects(){
      this.$http.post("/project/findAllProject", this.findProjectParam)
          .then(resp => {

            this.projects = resp.data.data.projects;
          })
    },

    add(){
      this.$http.post("/bugInfo/addNew")
          .then(resp => {

            console.log(resp);
            //  this.tableData = resp.data.data;
          })
    },
    delSelects(){
      this.$http.post("/bugInfo/deletes")
          .then(resp => {
            console.log(resp.data.data);
            //  this.tableData = resp.data.data;
          })
    },
    getBugTypes(){
      this.$http.post("/bugType/findBugInfo")
          .then(resp => {
            this.bugTypes = resp.data.data.bugTypes;
            console.log(this.bugTypes);
            //  this.tableData = resp.data.data;
          })
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    selectProject(){
      this.$http.post("/project/findAllProject", this.findProjectParam)
          .then(resp => {
            console.log("getProjects===================");
            console.log(resp);
            this.newprojects = resp.data.data.projects;
          })
    }
  },
  data() {
    return {
      addAndEditBugInfo:{
        projectId:'',
        parentIssueId:'',
        // ApiModelProperty(value = "缺陷名称")
        bugNum:'',
        //@ApiModelProperty(value = "缺陷描述")
        bugDesc:'',
        //@ApiModelProperty(value = "指派给")
        assignee:'',
        //@ApiModelProperty(value = "缺陷分类   type_code类型的代码")
        bugTypeId:'',
        //@ApiModelProperty(value = "缺陷严重  程度表severity_code类型的代码")
        severityId:'',
        //@ApiModelProperty(value = "优先级   缺陷优先级表priority_code类型的代码")
        PriorityId:'',
        //@ApiModelProperty(value = "预计开始日期")
        planStartTime:'',
        //@ApiModelProperty(value = "预计结束日期")
        planEndTime:'',
        //@ApiModelProperty(value = "实际开始日期")
        actStartTime:'',
        //@ApiModelProperty(value = "实际结束日期")
        actEndTime:'',
        //@ApiModelProperty(value = "预计工时数")
        planWorkHours:'',
        //@ApiModelProperty(value = "实际工时数")
        actWorkHours:'',
        //@ApiModelProperty(value = "分配时间")
        assignedTime:'',
        //@ApiModelProperty(value = "完成要求")
        doneCondition:'',
        //@ApiModelProperty(value = "完成百分比")
        doneRatio:'',
        //@ApiModelProperty(value = "缺陷状态")
        bugState:'',
        //@ApiModelProperty(value = "创建人")
        createPerson:'',
        //@ApiModelProperty(value = "创建时间")
        createTime:'',
        //@ApiModelProperty(value = "修改人")
        modifyPerson:'',
        //@ApiModelProperty(value = "修改时间")
        modifyTime:'',
      },
      dialogFormVisible:false,
      status: [{name:"新建",value:0},{name:"进行中",value:1},{name:"已解决",value:2},{name:"关闭",value:3}],
      tableData: [],
      allBugInfosParam: {
        startTime: null,
        endTime: null,
        projectId: null,
        status: null,
        pageIndex: 1,
        pageSize: 5
      },

      findProjectParam:{
        pageIndex: 1,
        pageSize: 99,
        keywords:'',
      },
      projects:[],
      formLabelWidth:'80px',
      bugTypes:[],
      savarityes:[],
      priorityes:[],
      multipleSelection: [],
      newprojects:[],
    }
  },
  created() {
    this.getBugInfors();
    this.getProjects();
    this.getBugTypes();
  },

}
</script>

<style scoped>

</style>
